﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace StoreWeb.system.userManage
{
    public partial class edit : System.Web.UI.Page
    {
        //BLL.Role role = new BLL.Role();
        Maticsoft.BLL.UserAdmin userbll = new Maticsoft.BLL.UserAdmin();
        BLL.DealersManage userdealers = new BLL.DealersManage();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
                hidid.Value = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(hidid.Value))
                {
                    Maticsoft.Model.UserAdmin ne = userbll.GetModel(Convert.ToInt32(hidid.Value));
                    username.Value = ne.username;

                    loginname.Value = ne.loginname;
                    password.Value = ne.password;
                    mobile.Value = ne.mobile;
                    email.Value = ne.email;
                    mobile.Value = ne.mobile;
                    description.Text = ne.description;

                    String roleid = new Maticsoft.BLL.UserRoleRelation().GetList(" userid=" + ne.id + " ").Tables[0].Rows[0][2].ToString();
                    ddlrole.SelectedValue = roleid;

                    dealers.Value = ne.dealersid;
                    if (ne.dealersid != "0")
                    {
                        selsectdealers.Value = userdealers.GetModel(Convert.ToInt32(ne.dealersid)).username + "【" + userdealers.GetModel(Convert.ToInt32(ne.dealersid)).dealersgrade + "级】";
                    }
                   
                }
            }
        }

        private void Bind()
        {
            Maticsoft.BLL.Role message = new Maticsoft.BLL.Role();
            //加载角色
            ddlrole.DataSource = message.GetList(" ");
            ddlrole.DataTextField = "rolename";
            ddlrole.DataValueField = "id";
            ddlrole.DataBind();
            ddlrole.Items.Insert(0, new ListItem { Value = "", Text = "------请选择角色------" });

        }
    }
}